

package volatie;

import lombok.extern.slf4j.Slf4j;

/**
 * @author ganbo
 * @date 2022/10/27 11:04
 */

@Slf4j
public class VolatileDemo {

    private volatile static boolean flag = true;


    public static void main(String[] args) throws InterruptedException {


        Thread t = new Thread(() -> {
            while (flag) {
//                System.out.println("======");
//                log.debug("==========");
            }
        });

        t.start();

        Thread.sleep(1000);
        System.out.println("停止 t");
        flag = false;
    }


}
